#include "DebugForm.h"
#include "ui_DebugForm.h"
#include <QTimer>
#include "src/Manager/ThreadPool.h"
#include <QMessageBox>
#include <QFileDialog>
#include "iconhelper.h"
#include "enumfontsome.h"


DebugForm::DebugForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::DebugForm)
{
    ui->setupUi(this);

    this->setWindowTitle("调试界面");

    initUIs();
    SysMembers::GetInstance()->moduleInitDone.connect([this](){
        CAD_model->setStringList(SysMembers::GetInstance()->cads);
    });

    // 回调函数，通知ui刷新当前进度
    ImgProvider::GetInstance()->reflushMsg.connect([this](PMsg msg){
        ui->progressBar->setValue(msg.curP);
        ui->progressBar->setMaximum(msg.totalP);
    });

}


void DebugForm::initUIs()
{
    gridModel = new QStandardItemModel(this);
    taskModel = new QStandardItemModel(this);

    child_frame = new FrameCorrect;
    child_camera = new CameraCorrect;
    child_machine = new MachineCorrect;
    child_sql = new SQLFuse;
    child_plc = new PLCControl;
    child_tool = new ToolForm;
    child_tubMove = new TubMove;
    child_sport  = new  RobotSport;

    clip = QApplication::clipboard();

    seam_model = new  QStringListModel;
    index_model = new QStringListModel;
    CAD_model = new QStringListModel;

    ui->cb_CAD->setModel(CAD_model);

    bool r;
    _para.ZS = ui->le_zs->text().toInt(&r);
    _para.ZF = ui->le_zf->text().toInt(&r);
    _para.YF = ui->le_yf->text().toInt(&r);
    _para.YS = ui->le_ys->text().toInt(&r);



    QFont font;
    font.setPixelSize(15);
    font.setBold(true);
    indexStackeds << ui->pb_PLC << ui->pb_machine<< ui->pb_sport << ui->pb_sql<< ui->pb_Tools
                  << ui->pb_camera<< ui->pb_frameCorrect << ui->pb_TubMove << ui->pb_sport_Robot;
    QColor normalBgColor = QColor("#292929");
    QColor hoverBgColor = QColor("#064077");
    QColor checkBgColor = QColor("#10689A");
    QColor normalTextColor = QColor("#FFFFFF");
    QColor hoverTextColor = Qt::yellow;
    QColor checkTextColor = QColor("#FFFFFF");

    QList<QChar> pixChar;
    pixChar << 0xf17b << 0xf002 << 0xf013 << 0xf021 << 0xf0e0 << 0xf135<< 0xf0e0 << 0xf135  << 0xf125;
    quint32 size = 24;
    quint32 pixWidth = 24;
    quint32 pixHeight = 24;

    for (int i = 0; i < indexStackeds.count(); i++) {
        auto *btn = indexStackeds.at(i);
        btn->setFont(font);
        btn->setPaddingLeft(20);
        btn->setShowLine(false);
        btn->setTextAlign(NaviButton::TextAlign_Center);
        btn->setLinePosition(NaviButton::LinePosition_Bottom);

        // ui->indexLayout->addWidget(btn);

         btn->setShowIcon(true);
         btn->setIconSpace(15);
         btn->setIconSize(QSize(24, 24));

        //分开设置图标
        QChar icon = pixChar.at(i);
        QPixmap iconNormal = IconHelper::Instance()->getPixmap(normalTextColor.name(), icon, size, pixWidth, pixHeight);
        QPixmap iconHover = IconHelper::Instance()->getPixmap(hoverTextColor.name(), icon, size, pixWidth, pixHeight);
        QPixmap iconCheck = IconHelper::Instance()->getPixmap(checkTextColor.name(), icon, size, pixWidth, pixHeight);
// 此处不设置图标了
//        btn->setIconNormal(iconNormal);
//        btn->setIconHover(iconHover);
//        btn->setIconCheck(iconCheck);

        btn->setNormalBgColor(normalBgColor);
        btn->setHoverBgColor(hoverBgColor);
        btn->setCheckBgColor(checkBgColor);
        btn->setNormalTextColor(normalTextColor);
        btn->setHoverTextColor(hoverTextColor);
        btn->setCheckTextColor(checkTextColor);
        btn->setFixedSize(140,44);
        connect(btn, SIGNAL(clicked(bool)), this, SLOT(indexClicked()));
    }

    //ui->tb_import->setFont( IconHelper::Instance()->GetFont());

    ui->pb_pos->setText(QChar(IconIdentity::icon_location_arrow));
    ui->pb_axis->setText(QChar(IconIdentity::icon_location_arrow));
    ui->pb_taskGo->setText(QChar(IconIdentity::icon_location_arrow));

    ui->listView_Grid->setModel(gridModel);
    ui->listView_Task->setModel(taskModel);


    ui->stackedWidget->addWidget(child_frame);
    ui->stackedWidget->addWidget(child_camera);
    ui->stackedWidget->addWidget(child_machine);
    ui->stackedWidget->addWidget(child_sql);
    ui->stackedWidget->addWidget(child_plc);
    ui->stackedWidget->addWidget(child_tool);
    ui->stackedWidget->addWidget(child_tubMove);
    ui->stackedWidget->addWidget(child_sport);


}

void DebugForm::indexClicked()
{
    NaviButton *b = (NaviButton *)sender();
    qDebug() << "当前按下" << b->text();
    for (int i = 0; i < indexStackeds.count(); i++) {
        NaviButton *btn = indexStackeds.at(i);
        btn->setChecked(b == btn);
    }
}


// 更新格点相关的视图模型
void DebugForm::updateGridList()
{
    gridModel->clear();
    for(auto it=d_data->cacheGrid.begin();it!=d_data->cacheGrid.end();++it)
    {
        auto r = it->first;
        QStandardItem *item = new QStandardItem(QString::fromStdString(r));
        gridModel->appendRow(item);
    }

    taskModel->clear();
    for(auto it=d_data->taskGrid.begin();it!=d_data->taskGrid.end();++it)
    {
        auto r = it->first;
        QStandardItem *item = new QStandardItem(QString::fromStdString(r));
        taskModel->appendRow(item);
    }

}


// 获取UI界面选择的最新POS
RobotPos DebugForm::getCurrent()
{
    RobotPos p;
    try{
        QString tb_name = ui->cb_table->currentText();
        QString seamid = ui->cb_seamid->currentText();
        QString index1 = ui->cb_index->currentText();
        QString query = "select pos from " + tb_name  + " where seamid="+seamid+" and index1="+index1;

        auto t = sqlProvider::GetInstance()->Get(query.toStdString());
        auto str = t.at(0).toString().toStdString();

        bool ret = str2Robot(str,p);
        if(!ret){
            std::cout << BOLDYELLOW << "数据库Pos转换错误:"<< RESET<<std::endl;
        }
        return p;
    }catch(...){
        qWarning()<<BOLDRED<<__FUNCTION__<<"从数据库获取当前Pos出现错误!"<<RESET;
    }

}



// 通过seamid获取basepoint
RobotPos DebugForm::getCadBasePoint(QString seamid)
{
    try{
        RobotPos pos;
        QString query = "select cadid from  seaminfo  where seamid=" + seamid ;
        auto t = sqlProvider::GetInstance()->Get(query.toStdString());
        QString cadid = t.at(0).toString();
        query = "select basepoint from  cad where cadid='" + cadid + "'";
        auto j = sqlProvider::GetInstance()->Get(query.toStdString());
        string basepoint = j.at(0).toString().toStdString();
        str2Robot(basepoint, pos);
        return pos;
    }
    catch(...){
        qWarning()<<BOLDYELLOW<<__FUNCTION__<<"获取basepoint出现异常"<<"\t"<<RESET;
    }
    return RobotPos::instance();

}

// 获取变位机角度然后转换矩阵
RobotPos DebugForm::getToolTransBase(QString seamid)
{
    RobotPos pos = RobotPos::instance();
    try {
         auto t = SQLHelper::GetBlade()->_p_tr->Get({"SEAMINFO"},{"motorposs","motorangle1s","motorangle2s"},{"seamid","'"+seamid.toStdString()+"'"});
         MOTORDEGRE f;
         f.angle1    = t.at(0).toDouble();
         f.angle2 = t.at(1).toDouble();
         f.angle3 = t.at(2).toDouble();
         pos = getPosition(f);
    } catch (MU_EXPS::SQL_EXPECTION e) {
        /// 写入日志
        qWarning()<<BOLDRED<<__FUNCTION__<<"获取变位机数据失败:"<<"\t"<<RESET;

    }
    return pos;

}

DebugForm::~DebugForm()
{
    delete ui;
}

// 生成摸点序列
void DebugForm::on_pb_GenVect_clicked()
{
    QString tb_name = ui->cb_table->currentText();
    QString seamid = ui->cb_seamid->currentText();
    QString index1 = ui->cb_index->currentText();

    DBIndex _index;
    _index.index1 = index1.toInt(new bool);
    _index.seamid = seamid.toInt(new bool);
    _index.db_name = tb_name.toStdString();
    if(tb_name.isEmpty() || seamid.isEmpty() || index1.isEmpty()){
        QMessageBox::warning(this, tr("生成格点异常"),
                                         tr("有必选项为空，不允许生成格点!\n"), QMessageBox::Cancel);
        return ;
    }
    RobotPos start = getCurrent();
    GenPosVector aPos_vect;     // 一组容器Pos
    posInBase(start,RorateMatrix.first,RorateMatrix.second);    //进行pos坐标轴变换

    MachineArgs arg;    // 获取应该到的变位机角度和地柜位置
    auto t = SQLHelper::GetBlade()->_p_tr->Get({"SEAMINFO"},{"motorAngle1s","motorAngle2s","motorPoss"},{"seamid","'"+seamid.toStdString()+"'"});
    auto s = SQLHelper::GetBlade()->_p_tr->Get({"SEAMINFO"},{"motor1speed","motor2speed","motor3speed"},{"seamid","'"+seamid.toStdString()+"'"});

    // 获取机器人安全位子
    auto _cadid = SQLHelper::GetBlade()->_p_tr->Get({"SEAMINFO"},{"cadid"},{"seamid","'"+seamid.toStdString()+"'"});
    std::string cid = _cadid.at(0).toString().toStdString();
    auto basePoint = SQLHelper::GetBlade()->_p_tr->Get({"CAD"},{"SAFELOC","SAFEANGLE1"},{"cadid","'"+cid+"'"});

    try{
        arg.r =  t.at(0).toDouble();
        arg.a =  t.at(1).toDouble();
        arg.u =  t.at(2).toDouble();

        arg.uspeed = s.at(0).toDouble();
        arg.rspeed = s.at(1).toDouble();
        arg.aspeed = s.at(2).toDouble();
        arg.Su =  basePoint.at(0).toBool();
        arg.Sa =  basePoint.at(1).toBool();
    }catch(...){
        qWarning()<<BOLDRED<<__FUNCTION__<<"数据库可能没有该字段，请检查当前数据库版本!"<<RESET;
    }

    start = start>RobotTCP::CAMERA;     /* 转换为相机中心点 */

    aPos_vect = MoniProvider::GenRobotPos(start,_para.YS,_para.ZS,_para.YF,_para.ZF,arg,_index,_para.roration,true);

    string desc = DateTime::getClock()+"-"+tb_name.toStdString()+"-"+seamid.toStdString()+"-"+index1.toStdString() + "-" + _para.roration.toStr();
    d_data->cacheGrid[desc] = aPos_vect;

    updateGridList();
}






// 表单切换
void DebugForm::on_cb_table_activated(const QString &arg1)
{
    if(arg1.isEmpty() ) return;
    QStringList f;

    seam_model->setStringList(f);
    index_model->setStringList(f);

    QString query = "select seamid from " + arg1 ;
    query+= " where seamid in (select seamid from seaminfo where cadid='"+cadName+"')";
    auto t = sqlProvider::GetInstance()->Get(query.toStdString());  /* 双重筛选 */

    f = transVarToQString(t);
    seam_model->setStringList(f);
    ui->cb_seamid->setModel(seam_model);
}

// 当选择了一个索引之后
void DebugForm::on_cb_index_activated(const QString &arg1)
{
    // qDebug()<<arg1;
}

// 焊缝出现切换
void DebugForm::on_cb_seamid_activated(const QString &arg1)
{
    if(arg1.isEmpty() ) return;
    QString tb_name = ui->cb_table->currentText();
    QString query = "select index1 from "  +tb_name +  " where seamid=" + arg1;
    try{
        auto t = sqlProvider::GetInstance()->Get(query.toStdString());
        QStringList f = transVarToQString(t);
        index_model->setStringList(f);
        ui->cb_index->setModel(index_model);
    }catch(...){
        qDebug()<<__FUNCTION__<<"刷新index1-Combobox出现异常";
    }

    try{
        // 获取cad basePoint-----每次选择焊缝后就会触发更新
        RorateMatrix.first = getCadBasePoint(arg1);     // 获取工具坐标系的变换关系
        RorateMatrix.second = getToolTransBase(arg1);
    }catch(...){
        qDebug()<<__FUNCTION__<<"生成坐标变换失败";
    }

}


// 从缓存容器里移动至任务容器
void DebugForm::on_pb_insertTask_clicked()
{
    QModelIndex index = ui->listView_Grid->currentIndex();
    QVariant name = gridModel->data(index, Qt::DisplayRole);  //获取当前选择的项的文本
    if(index.row()<0){
            QMessageBox::warning(this, tr("运行失败"),tr("没有选择任务单元，无法添加!"),QMessageBox::Cancel);
            return;
    }
    d_data->taskGrid[name.toString().toStdString()] = d_data->cacheGrid[name.toString().toStdString()];
    d_data->cacheGrid.erase(name.toString().toStdString() );
    updateGridList();
//    auto  it= cacheGrid.find(name.toString().toStdString());
//    cacheGrid.erase(it);      // 使用迭代器去map

}

void DebugForm::on_pb_removeTask_clicked()
{
    QModelIndex index = ui->listView_Task->currentIndex();
    QVariant name = taskModel->data(index, Qt::DisplayRole);  //获取当前选择的项的文本
    if(index.row()<0){
            QMessageBox::warning(this, tr("运行失败"),tr("没有选择任务单元，无法添加!"),QMessageBox::Cancel);
            return;
    }
    d_data->cacheGrid[name.toString().toStdString()] = d_data->taskGrid[name.toString().toStdString()];
    d_data->taskGrid.erase(name.toString().toStdString() );
    updateGridList();
}

void DebugForm::on_pb_deleteCache_clicked()
{
    QModelIndex index = ui->listView_Grid->currentIndex();
    QVariant name = gridModel->data(index, Qt::DisplayRole);  //获取当前选择的项的文本
    if(index.row()<0){
            QMessageBox::warning(this, tr("运行失败"),tr("没有选择任务单元，无法添加!"),QMessageBox::Cancel);
            return;
    }
    gridModel->removeRow(index.row());
    d_data->cacheGrid.erase(name.toString().toStdString());
    updateGridList();
}

void DebugForm::on_pb_deleteTask_clicked()
{
    QModelIndex index = ui->listView_Task->currentIndex();
    QVariant name = gridModel->data(index, Qt::DisplayRole);  //获取当前选择的项的文本
    if(index.row()<0){
            QMessageBox::warning(this, tr("运行失败"),tr("没有选择任务单元，无法添加!"),QMessageBox::Cancel);
            return;
    }
    d_data->taskGrid.erase(name.toString().toStdString() );
    updateGridList();
}


// 添加所有格点缓存
void DebugForm::on_pb_AddAll_clicked()
{
    if(d_data->taskGrid.empty())
        d_data->cacheGrid.swap(d_data->taskGrid);
    else{
        for(auto it = d_data->cacheGrid.begin();it != d_data->cacheGrid.end();it++){
            d_data->taskGrid[it->first] = it->second;
        }
        d_data->cacheGrid.clear();
    }
    updateGridList();
}

void DebugForm::on_pb_clearCache_clicked()
{
    d_data->cacheGrid.clear();
    d_data->taskGrid.clear();
    updateGridList();
}

// 开始格点任务
void DebugForm::on_pb_startTask_clicked()
{
    std::thread t1([this](){
        static int index = 0;
        int all = d_data->taskGrid.size();
        QString nnn = "0/" + QString::number(all);
        ui->proAll->setText(nnn);
        ui->pb_startTask->setEnabled(false);
        for(auto it=d_data->taskGrid.begin();it!=d_data->taskGrid.end();++it){
            /* 选择运动模式 */
            if(1 == ui->cb_grid_mode->currentIndex() ){
                ImgProvider::GetInstance()->callImageConPoss(it->first,it->second);
            }else if(0 == ui->cb_grid_mode->currentIndex() ){
                ImgProvider::GetInstance()->callImagePoss(it->first,it->second);
            }else{

            }

            index++;
            QString proc = QString::number(index) + "/" + QString::number(all);
            ui->proAll->setText(proc);
        }
        index = 0;
        ui->proAll->setText("0/0");
        ui->pb_startTask->setEnabled(true);
    });
    t1.detach();

}

// 设置Y方向终点
void DebugForm::on_pb_ys_clicked()
{
    bool r;
    _para.YS = ui->le_ys->text().toInt(&r);
    if(!r){
        QMessageBox::warning(this, tr("运行失败"),tr("参数设置失败，非法数据!"),QMessageBox::Cancel);
    }
}

void DebugForm::on_pb_yf_clicked()
{
    bool r;
    _para.YF = ui->le_yf->text().toInt(&r);
    if(!r){
        QMessageBox::warning(this, tr("运行失败"),tr("参数设置失败，非法数据!"),QMessageBox::Cancel);
    }
}

void DebugForm::on_pb_zs_clicked()
{
    bool r;
    _para.ZS = ui->le_zs->text().toInt(&r);
    if(!r){
        QMessageBox::warning(this, tr("运行失败"),tr("参数设置失败，非法数据!"),QMessageBox::Cancel);
    }
}

void DebugForm::on_pb_zf_clicked()
{
    bool r;
    _para.ZF = ui->le_zf->text().toInt(&r);
    if(!r){
        QMessageBox::warning(this, tr("运行失败"),tr("参数设置失败，非法数据!"),QMessageBox::Cancel);
    }
}

void DebugForm::on_pb_pos_clicked()
{
    auto t = ui->le_targetPos->text().toStdString();

    RobotPos pos = RobotPos::instance(t);
    //
    RobotHelper::GetInstance()->ABSMove(pos,SysMembers::GetInstance()->debugRobotSpeed);
}


void DebugForm::on_pb_axis_clicked()
{
    auto t = ui->le_targetAxis->text().toStdString();
    RobotHelper::GetInstance()->ABSMoveAxis(RobotAxle::instance(t),SysMembers::GetInstance()->debugRobotSpeed);
}

void DebugForm::on_pb_frameCorrect_clicked(bool checked)
{
    ui->stackedWidget->setCurrentIndex(1);
}

void DebugForm::on_pb_sport_clicked(bool checked)
{
    ui->stackedWidget->setCurrentIndex(0);
}

void DebugForm::on_pb_camera_clicked(bool checked)
{
    ui->stackedWidget->setCurrentIndex(2);
}

void DebugForm::on_pb_machine_clicked(bool checked)
{
    ui->stackedWidget->setCurrentIndex(3);
}

void DebugForm::on_pb_sql_clicked(bool checked)
{
    ui->stackedWidget->setCurrentIndex(4);
}

void DebugForm::on_pb_PLC_clicked(bool checked)
{
    ui->stackedWidget->setCurrentIndex(5);
}

void DebugForm::on_pb_copyPos_clicked()
{
    RobotPos p = RobotHelper::GetInstance()->getCurrentPos();
    clip->setText(QString::fromStdString(p.toStr()));
}

void DebugForm::on_cb_CAD_activated(const QString &arg1)
{
    if(arg1.isNull()){
        qWarning()<<BOLDRED<<__FUNCTION__<<"没有选择CAD工件!"<<RESET;
    }
    cadName = arg1;
}

void DebugForm::on_pb_Tools_clicked(bool checked)
{
    ui->stackedWidget->setCurrentIndex(6);
}


void DebugForm::on_pb_copyAxle_clicked()
{
    RobotAxle p = RobotHelper::GetInstance()->_robot->getCurrAxle();
    clip->setText(QString::fromStdString(p.toStr()));
}




void DebugForm::on_pb_TubMove_clicked(bool checked)
{
    ui->stackedWidget->setCurrentIndex(7);
}

void DebugForm::on_pb_sport_Robot_clicked(bool checked)
{
    ui->stackedWidget->setCurrentIndex(8);
}


void DebugForm::on_pb_taskGo_clicked()
{
    qDebug()<<CYAN<<QString::fromStdString(newDBPos.toStr())<<RESET;
    RobotHelper::GetInstance()->ABSMove(newDBPos,SysMembers::GetInstance()->debugRobotSpeed);
}


void DebugForm::updatePos(std::string f)
{
    auto isDB = std::get<3>(d_data->cacheGrid[f]);
    if(isDB){
        auto _curIndex = std::get<4>(d_data->cacheGrid[f]);
        ui->lb_vec->setText( QString::fromStdString(_curIndex.db_name));
        ui->lb_seam->setText(QString::number(_curIndex.seamid));
        ui->lb_index->setText(QString::number(_curIndex.index1));
    }else{
        ui->lb_vec->setText( "NO-DB");
        ui->lb_seam->setText("NAN");
        ui->lb_index->setText("NAN");
    }

    newDBPos = RobotPos::instance(std::get<1>(d_data->cacheGrid[f]).toStr());    // 此处获取到的是基于工件坐标系的位置
//    posInBase(newDBPos,first,second);

//    DBIndex _curIndex;
//    std::regex e("([[:w:]]+)-([[:w:]]+)-([[:w:]]+)-([[:w:]]+)");
//    std::smatch m;
//    bool found = regex_search(f, m, e);
//    if(found){
//        _curIndex.db_name = m.str(2) ;
//        _curIndex.seamid = atoi(m.str(3).c_str())  ;
//        _curIndex.index1 = atoi(m.str(4).c_str())  ;
//    }else {
//        std::cout << BOLDYELLOW << "验证数据正则表达式出现错误！"<< RESET<<std::endl;
//    }

//    auto first = getCadBasePoint(QString::number(_curIndex.seamid));     // 获取工具坐标系的变换关系
//    auto second = getToolTransBase(QString::number(_curIndex.seamid));

//    auto pos = SQLHelper::GetBlade()->p()->Get(_curIndex.db_name,{"pos"},{"seamid","'" + to_string(_curIndex.seamid) +"'" ,
//                                                                          "index1","'" + to_string(_curIndex.index1) +"'" });

   //进行pos坐标轴变换
}

void DebugForm::on_listView_Grid_clicked(const QModelIndex &index)
{
    QVariant name = gridModel->data(index, Qt::DisplayRole);  //获取当前选择的项的文本
    if(index.row()<0){
            QMessageBox::warning(this, tr("运行失败"),tr("没有选择数据!"),QMessageBox::Cancel);
            return;
    }
    auto f = name.toString().toStdString();
    updatePos(f);
}

void DebugForm::on_listView_Task_clicked(const QModelIndex &index)
{
    QVariant name = gridModel->data(index, Qt::DisplayRole);  //获取当前选择的项的文本
    if(index.row()<0){
            QMessageBox::warning(this, tr("运行失败"),tr("没有选择数据!"),QMessageBox::Cancel);
            return;
    }
    auto f = name.toString().toStdString();
    updatePos(f);
}



void DebugForm::on_pb_CreatUserPos_clicked()
{
    bool rtcp = true;
    bool rtcpc = true;
    double rz = ui->le_rz->text().toDouble(&rtcp);
    _para.roration.a = rz;
    rtcpc &= rtcp;
    double rx = ui->le_rx->text().toDouble(&rtcp);
    _para.roration.c = rx;
    rtcpc &= rtcp;
    double ry = ui->le_ry->text().toDouble(&rtcp);
    _para.roration.b = ry;
    rtcpc &= rtcp;
    double dz = ui->le_dz->text().toDouble(&rtcp);
    _para.roration.z = dz;

    if(!rtcpc){
        pushWarn("tcp旋转参数输入失败，请重新输入格点",MU_ERROR_MODULE_APP);
        return ;
    }


    auto posstr= ui->le_userPos->text().toStdString();
    RobotPos start = RobotPos::instance(posstr);

    if(1 == ui->cb_IPMode->currentIndex()){
        start = start>RobotTCP::CAMERA;     /* 转换为相机中心点 */
    }else{

    }

    auto vect = MoniProvider::GenRobotPos(start,_para.YS,_para.ZS,_para.YF,_para.ZF,_para.roration);

    string desc = DateTime::getFullTime("/")+"-"+ "NODB" +"-"+"NAN"+"-"+"NAN" ;
    if(0 != _para.nameRule ){
        desc +=  ("-" + _para.roration.toStr());
    }

    d_data->cacheGrid[desc] = vect;

    updateGridList();
}





void DebugForm::on_pb_rule_clicked()
{
    _para.nameRule = ui->cb_nameRule->currentIndex();
}
